using Joy.Erp.BasicArchives;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace Joy.Erp.Ufida.Pmc
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("MaterialManagementPlatform")]
    [Route("api/basic-archives/material-management-platform")]
    public class MaterialManagementPlatformController : BasicArchivesController, IMaterialManagementPlatformAppService
    {
        protected IMaterialManagementPlatformAppService MaterialManagementPlatformAppService => 
            LazyServiceProvider.LazyGetRequiredService<IMaterialManagementPlatformAppService>();

        /// <summary>
        /// 加载供需数据到缓存
        /// </summary>
        [HttpPost]
        [Route("load-supply-demand-data")]
        public Task<bool> LoadSupplyDemandDataAsync(LoadSupplyDemandDataInput input)
        {
            return MaterialManagementPlatformAppService.LoadSupplyDemandDataAsync(input);
        }

        /// <summary>
        /// 获取料品供需平衡分析数据（分页）
        /// </summary>
        [HttpPost]
        [Route("material-balance-analysis")]
        public Task<PagedResultDto<MaterialBalanceAnalysisDto>> GetMaterialBalanceAnalysisAsync(GetMaterialBalanceInput input)
        {
            return MaterialManagementPlatformAppService.GetMaterialBalanceAnalysisAsync(input);
        }

        /// <summary>
        /// 清除缓存
        /// </summary>
        [HttpDelete]
        [Route("clear-cache")]
        public Task ClearCacheAsync()
        {
            return MaterialManagementPlatformAppService.ClearCacheAsync();
        }
    }
}

